package com.atguigu.spzx.utils;

import com.atguigu.spzx.model.entity.system.SysUser;
import com.atguigu.spzx.model.entity.user.UserInfo;

public class AuthContextUtils {
//    创建threadLocal 对象  存储系统管理员
    private static final ThreadLocal<SysUser> threadLocal = new ThreadLocal<>();
//    添加数据
    public static void set(SysUser sysUser){
        threadLocal.set(sysUser);
    }
//    获取数据
    public static SysUser get(){
        return  threadLocal.get();
    }
//    删除数据
    public static void remove(){
        threadLocal.remove();
    }

//    创建 threadLoacl对象 存储用户对象
    private static final ThreadLocal<UserInfo> userInfoThreadLocal = new ThreadLocal<>();
    public static void setUserInfo(UserInfo userInfo){
        userInfoThreadLocal.set(userInfo);
    }

    public static UserInfo getUserInfo(){
        return userInfoThreadLocal.get();
    }
    public static void removeUserInfo(){
        userInfoThreadLocal.remove();
    }
}
